
open_project ${PROJECT_NAME}_prj

open_solution "solution1"
set_part ${FPGA_PART}
create_clock -period ${CLOCK_PERIOD} -name default

set_top ${PROJECT_NAME}_top

add_files ${CMAKE_CURRENT_SOURCE_DIR}/../axi_utils.cpp
add_files ${CMAKE_CURRENT_SOURCE_DIR}/../ipv4/ipv4_utils.cpp -cflags "-I${CMAKE_CURRENT_BINARY_DIR}"
add_files ${CMAKE_CURRENT_SOURCE_DIR}/../ipv4/ipv4.cpp -cflags "-I${CMAKE_CURRENT_BINARY_DIR}"
add_files ${CMAKE_CURRENT_SOURCE_DIR}/../ipv6/ipv6.cpp -cflags "-I${CMAKE_CURRENT_BINARY_DIR}"
add_files ${CMAKE_CURRENT_SOURCE_DIR}/../udp/udp.cpp -cflags "-I${CMAKE_CURRENT_BINARY_DIR}"
add_files ${CMAKE_CURRENT_SOURCE_DIR}/../ib_transport_protocol/ib_utils.cpp -cflags "-I${CMAKE_CURRENT_BINARY_DIR}"
add_files ${CMAKE_CURRENT_SOURCE_DIR}/../ib_transport_protocol/ib_transport_protocol.cpp -cflags "-I${CMAKE_CURRENT_BINARY_DIR}"
add_files ${CMAKE_CURRENT_SOURCE_DIR}/../ib_transport_protocol/read_req_table.cpp -cflags "-I${CMAKE_CURRENT_BINARY_DIR}"
add_files ${CMAKE_CURRENT_SOURCE_DIR}/../ib_transport_protocol/transport_timer.cpp -cflags "-I${CMAKE_CURRENT_BINARY_DIR}"
add_files ${CMAKE_CURRENT_SOURCE_DIR}/../ib_transport_protocol/retransmitter/retransmitter.cpp -cflags "-I${CMAKE_CURRENT_BINARY_DIR}"
add_files ${CMAKE_CURRENT_SOURCE_DIR}/../ib_transport_protocol/state_table.cpp -cflags "-I${CMAKE_CURRENT_BINARY_DIR}"
add_files ${CMAKE_CURRENT_SOURCE_DIR}/../ib_transport_protocol/conn_table.cpp -cflags "-I${CMAKE_CURRENT_BINARY_DIR}"
add_files ${CMAKE_CURRENT_SOURCE_DIR}/../ib_transport_protocol/msn_table.cpp -cflags "-I${CMAKE_CURRENT_BINARY_DIR}"
add_files ${CMAKE_CURRENT_SOURCE_DIR}/rocev2.cpp -cflags "-I${CMAKE_CURRENT_BINARY_DIR}"


add_files -tb ${CMAKE_CURRENT_SOURCE_DIR}/test_rocev2.cpp -cflags "-I${CMAKE_CURRENT_BINARY_DIR}"


config_rtl -disable_start_propagation

#Check which command
set command [lindex $argv 2]

if {$command == "synthesis"} {
   csynth_design
} elseif {$command == "csim"} {
   csim_design -argv {${CMAKE_CURRENT_SOURCE_DIR}/write_read_read_large_receiver.in ${CMAKE_CURRENT_SOURCE_DIR}/write_read_read_large_receiver.out ${CMAKE_CURRENT_SOURCE_DIR}/rdma_txwriteread.in ${CMAKE_CURRENT_SOURCE_DIR}/rdma_txwriteread.out}
} elseif {$command == "ip"} {
   export_design -format ip_catalog -ipname "rocev2" -display_name "RoCEv2 Endpoint" -description "" -vendor "ethz.systems.fpga" -version "0.82"
} elseif {$command == "installip"} {
   file mkdir ${IPREPO_DIR}
   file delete -force ${IPREPO_DIR}/${PROJECT_NAME}
   file copy -force ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_prj/solution1/impl/ip ${IPREPO_DIR}/${PROJECT_NAME}/
} else {
   puts "No valid command specified. Use vivado_hls -f make.tcl <synthesis|csim|ip|installip> ."
}


exit
